
package com.linkelee.biz.service.oss.cloud;


import com.linkelee.api.constant.CloudConfigConstant;
import com.linkelee.api.enums.CloudServiceEnum;
import com.linkelee.api.service.sys.ISysConfigService;
import com.linkelee.api.util.SpringContextUtils;

/**
 * 文件上传Factory
 *
 * @author lsl 154751575@qq.com
 */
public final class OSSFactory {
    private static ISysConfigService sysConfigService;

    static {
        OSSFactory.sysConfigService = (ISysConfigService) SpringContextUtils.getBean("sysConfigService");
    }

    public static CloudStorageService build(){
        //获取云存储配置信息
        CloudStorageConfig config = sysConfigService.getConfigObject(CloudConfigConstant.CLOUD_STORAGE_CONFIG_KEY, CloudStorageConfig.class);

        if(config.getType() == CloudServiceEnum.QINIU.getValue()){
            return new QiniuCloudStorageService(config);
        }else if(config.getType() == CloudServiceEnum.ALIYUN.getValue()){
            return new AliyunCloudStorageService(config);
        }else if(config.getType() == CloudServiceEnum.QCLOUD.getValue()){
            return new QcloudCloudStorageService(config);
        }

        return null;
    }

}
